# -*- coding: utf-8 -*-
"""
__mktime__ = '2019/4/14'
__author__ = 'Just'
__filename__ = 'read_record'
"""
from sqlalchemy import Column, Integer, String, SmallInteger, orm, ForeignKey
from app.model.base import BaseModel, db


class ReadRecord(BaseModel):
    """用户阅读记录"""
    __tablename__ = 'read_record'

    id = Column(Integer, primary_key=True, autoincrement=True)
    mid = Column(Integer, ForeignKey('comic.mid'), nullable=False, comment='漫画id')
    sid = Column(Integer, ForeignKey('comic_section.sid'), nullable=False, comment='章节id')
    pid = Column(Integer, ForeignKey('comic_image.pid'), default=1, comment='进度id 图片次序索引')
    uid = Column(Integer, ForeignKey('user.id'), nullable=False, comment='用户id')

    @orm.reconstructor
    def __init__(self):
        # 序列化列表
        self.fields = ['id', 'uid', 'mid', 'sid', 'pid']
